AllKinds tests: interoperability with '--all'
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>
Mon, 10 Apr 2017 18:18:08 +0000 (20:18 +0200)
committerBen Wiederhake <BenWiederhake.GitHub@gmx.de>
Mon, 10 Apr 2017 18:20:32 +0000 (20:20 +0200)
tests/build.rs

index 325d0e81c508771a1a44e52bd2d3a1b6b3e0c0d9..a86493f148013aafa65e56a73095ca76139586cb 100644 (file)
@@ -2804,6 +2804,51 @@ fn build_all_workspace() {
                        [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n"));
 }
 
+#[test]
+fn build_all_workspace_implicit_examples() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.1.0"
+
+            [dependencies]
+            bar = { path = "bar" }
+
+            [workspace]
+        "#)
+        .file("src/lib.rs", "")
+        .file("src/bin/a.rs", "fn main() {}")
+        .file("src/bin/b.rs", "fn main() {}")
+        .file("examples/c.rs", "fn main() {}")
+        .file("examples/d.rs", "fn main() {}")
+        .file("bar/Cargo.toml", r#"
+            [project]
+            name = "bar"
+            version = "0.1.0"
+        "#)
+        .file("bar/src/lib.rs", "")
+        .file("bar/src/bin/e.rs", "fn main() {}")
+        .file("bar/src/bin/f.rs", "fn main() {}")
+        .file("bar/examples/g.rs", "fn main() {}")
+        .file("bar/examples/h.rs", "fn main() {}");
+
+    assert_that(p.cargo_process("build")
+                 .arg("--all").arg("--examples"),
+                execs().with_status(0)
+                       .with_stderr("[..] Compiling bar v0.1.0 ([..])\n\
+                       [..] Compiling foo v0.1.0 ([..])\n\
+                       [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n"));
+    assert_that(&p.bin("a"), is_not(existing_file()));
+    assert_that(&p.bin("b"), is_not(existing_file()));
+    assert_that(&p.bin("examples/c"), existing_file());
+    assert_that(&p.bin("examples/d"), existing_file());
+    assert_that(&p.bin("e"), is_not(existing_file()));
+    assert_that(&p.bin("f"), is_not(existing_file()));
+    assert_that(&p.bin("examples/g"), existing_file());
+    assert_that(&p.bin("examples/h"), existing_file());
+}
+
 #[test]
 fn build_all_virtual_manifest() {
     let p = project("workspace")
@@ -2839,6 +2884,53 @@ fn build_all_virtual_manifest() {
                        [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n"));
 }
 
+#[test]
+fn build_all_virtual_manifest_implicit_examples() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [workspace]
+            members = ["foo", "bar"]
+        "#)
+        .file("foo/Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.1.0"
+        "#)
+        .file("foo/src/lib.rs", "")
+        .file("foo/src/bin/a.rs", "fn main() {}")
+        .file("foo/src/bin/b.rs", "fn main() {}")
+        .file("foo/examples/c.rs", "fn main() {}")
+        .file("foo/examples/d.rs", "fn main() {}")
+        .file("bar/Cargo.toml", r#"
+            [project]
+            name = "bar"
+            version = "0.1.0"
+        "#)
+        .file("bar/src/lib.rs", "")
+        .file("bar/src/bin/e.rs", "fn main() {}")
+        .file("bar/src/bin/f.rs", "fn main() {}")
+        .file("bar/examples/g.rs", "fn main() {}")
+        .file("bar/examples/h.rs", "fn main() {}");
+
+    // The order in which foo and bar are built is not guaranteed
+    assert_that(p.cargo_process("build")
+                 .arg("--all").arg("--examples"),
+                execs().with_status(0)
+                       .with_stderr_contains("[..] Compiling bar v0.1.0 ([..])")
+                       .with_stderr_contains("[..] Compiling foo v0.1.0 ([..])")
+                       .with_stderr("[..] Compiling [..] v0.1.0 ([..])\n\
+                       [..] Compiling [..] v0.1.0 ([..])\n\
+                       [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n"));
+    assert_that(&p.bin("a"), is_not(existing_file()));
+    assert_that(&p.bin("b"), is_not(existing_file()));
+    assert_that(&p.bin("examples/c"), existing_file());
+    assert_that(&p.bin("examples/d"), existing_file());
+    assert_that(&p.bin("e"), is_not(existing_file()));
+    assert_that(&p.bin("f"), is_not(existing_file()));
+    assert_that(&p.bin("examples/g"), existing_file());
+    assert_that(&p.bin("examples/h"), existing_file());
+}
+
 #[test]
 fn build_all_member_dependency_same_name() {
     let p = project("workspace")